<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of loginController
 *
 * @author nstevens
 */
include_once 'model/portfolioModelClass.php';

class loginController {

    private $model;

    public function __construct($model) {
        $this->model = $model;
    }

    function loginRequest() {
        $this->model->string = "";
        if (strcmp($_SESSION['role'], "pi") === 0) {
            $this->model->string .= $this->model->getBasicHeader("PI Main");
            $this->model->string .= '<br><br>';
            $result = executeSelect("SELECT * FROM requirement ORDER by fiscalYear ASC, priority ASC");
            $this->model->string .= getRequirementsTable($result, false);
            $this->model->string .= '<br>';
            $this->model->string .= getCloseTag("body");
            $this->model->string .= getCloseTag("html");
        } else if (strcmp($_SESSION['role'], "admin") === 0) {
            $this->model->string .= $this->model->getBasicHeader("Admin Main");
            $this->model->string .= '<br><br>';
            $result = executeSelect("SELECT * FROM requirement ORDER by fiscalYear ASC, priority ASC");
            $this->model->string .= getRequirementsTable($result, false);
            $this->model->string .= getCloseTag("body");
            $this->model->string .= getCloseTag("html");
        } else if (strcmp($_SESSION['role'], "pireviewer") === 0) {
            $this->model->string .= $this->model->getBasicHeader("Reviewer Main");
            $this->model->string .= '<br><br>';
            $result = executeSelect("SELECT * FROM requirement ORDER by fiscalYear ASC, priority ASC");
            $this->model->string .= getRequirementsTable($result, false);
            $this->model->string .= getCloseTag("body");
            $this->model->string .= getCloseTag("html");
        } else if (strcmp($_SESSION['role'], "piapprover") === 0) {
            $this->model->string .= $this->model->getBasicHeader("Approver Main");
            $this->model->string .= '<br><br>';
            $result = executeSelect("SELECT * FROM requirement ORDER by fiscalYear ASC, priority ASC");
            $this->model->string .= getRequirementsTable($result, false);
            $this->model->string .= getCloseTag("body");
            $this->model->string .= getCloseTag("html");
        } else if (strcmp($_SESSION['role'], "cnmocUser") === 0) {
            $this->model->string .= $this->model->getBasicHeader("CNMOC Main");
            $this->model->string .= getCloseTag("body");
            $this->model->string .= getCloseTag("html");
            echo '<br><br>';
            $result = executeSelect("SELECT * FROM requirement ORDER by fiscalYear ASC, priority ASC");
            $this->model->string .= getRequirementsTable($result, false);
        } else {
            header("location:unknownRole.php");
        }
    }

    function toggleUserRole() {
        toggleRole();
        $url = $_SERVER['HTTP_REFERER'];
        header("location:$url");
    }

    //PI APPROVER MAIN PAGE**********************************************************
}

?>
